package com.zt.teacher.controller;

import com.zt.common.pojo.exam.ExamQuestionBank;
import com.zt.common.pojo.common.JsonResult;
import com.zt.teacher.service.ExamQuestionBankService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * description:
 * author:zt
 * date:2022-01-17
 */
@RestController
@CrossOrigin
@RequestMapping("examQuestion")
@Api("考试试题模块")
public class ExamQuestionBankController {

    @Autowired
    private ExamQuestionBankService examQuestionBankService;

    @GetMapping("getQuestion/{courseId}")
    @ApiOperation("根据课程id获取所有已有试题")
    public JsonResult<List<ExamQuestionBank>> getQuestionByCourseId(@PathVariable int courseId){
        return JsonResult.success(examQuestionBankService.getQuestionByCourseId(courseId));
    }

    @PostMapping("add")
    @ApiOperation("添加试题")
    public JsonResult<Integer> addQuestion(@RequestBody ExamQuestionBank examQuestionBank){
        return JsonResult.success(examQuestionBankService.insert(examQuestionBank));
    }
}
